package com.jiguang.property.config;

import com.alibaba.fastjson.annotation.JSONField;
import com.jiguang.property.dto.UserInfoDTO;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

@Data
@NoArgsConstructor
public class LoginUser implements UserDetails {

    private UserInfoDTO ucenter;

    public LoginUser(UserInfoDTO ucenter) {
        this.ucenter = ucenter;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @JSONField(serialize = false)
    @Override
    public String getPassword() {
        return ucenter.getPassword();
    }

    @JSONField(serialize = false)
    @Override
    public String getUsername() {
        return ucenter.getUsername();
    }

    @JSONField(serialize = false)
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @JSONField(serialize = false)
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @JSONField(serialize = false)
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @JSONField(serialize = false)
    @Override
    public boolean isEnabled() {
        return true;
    }
}
